package com.sh.data.engine.domain.util;

import java.util.ArrayList;
import java.util.List;

public class PaginateUtil {
    public static <T> List<T> paginate(List<T> list, int page, int pageSize) {
        if (list == null || list.isEmpty()) {
            return new ArrayList<>();
        }
        int fromIndex = (page - 1) * pageSize;
        int toIndex = page * pageSize;
        return list.subList(fromIndex, Math.min(toIndex, list.size()));
    }
}
